package csu.jpetstore.jpetstore.service;

import csu.jpetstore.jpetstore.domain.Item;
import csu.jpetstore.jpetstore.domain.Product;
import csu.jpetstore.jpetstore.repository.ItemRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ItemService {
    @Autowired
    ItemRepository itemRepository;

    @Autowired
    ProductService productService;

    public List<Item> getAllByProductId(int productId){
        Product product = productService.getProduct(productId);
        return itemRepository.findAllByProduct(product);
    }
}
